package actions;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;



import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import db.DbConnectionPool;
import db.DbException;
import forms.formDecision;

public class decisionAction extends Action{
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws DbException {
		formDecision iform = (formDecision) form;
		HttpSession session = request.getSession();
		try {
			Connection conn = DbConnectionPool.getConnection();
			
			PreparedStatement pStmt = conn.prepareStatement("UPDATE student_status SET student_status = ? WHERE user_id='"+session.getAttribute("appId")+"'");
			pStmt.setString(1, iform.getDec());
			pStmt.executeUpdate();
			conn.commit();
			pStmt.close();
			conn.close();
		} catch (SQLException ex) {
			throw new DbException(ex);
		} catch (NamingException ex) {
			throw new DbException(ex);
		}
		return mapping.findForward("success");
		
	}
}
